home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 10
/
The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso
/
PC_SIGCD
/
03
/
7
/
DISK0378.ZIP
/
FSEDIT.DOC
< prev
next >
Wrap
Text File
|
1983-04-10
|
10KB
|
168 lines
From: Jan. 83 issue of Microcomputing
Modified by: Terry G. Bailey
Full Screen Editor
Following is a copy of the article describing this program by D. E. Cortesi
IBM's MVP (Most Valuable Program)
The most important piece of software in any computer system, for me,
is its editor.
The editor is used for just about everthing: source programs, memos,
business letters, batch command files, articles, datafiles...Everything
that goes onto a disk gets there throught the editor program, or descends
from something that did.
When I was loaned an IBM Personal Computer, I found that it lacked an
editor. It has Edlin, but I don't find that program an acceptable tool.
I've been using full-screen editors for some years now, so I find it difficult
to go back to a line-oriented editor - especially one as rudimentary as
Edlin.
So there the machine sat, waiting for me to give it something to do. But
what I needed was some kind of stop-gap - an editor that I could tolerate
until a professional product becomes available.
My solution was to write a stopgap editor in Basic.
The resulting program is interesting in several ways. It's an example
of how much you can accomplish in IBM's Basic, and of how you can use the
Basic language in a structured style of programming. And it's a scale
model of a full-screen editor, so it can serve as a test bed for ideas
that you might have on how an editor should work.
PROGRAM OBJECTIVES.
The Stopgap Editor was an unusual programming project. It was the first
time I'd written a program with the intention of using it heavily for a short
time and then throwing it away.
The first requirement was that it had to go together quickly; that dictated
a clean, simple design using straightforward techniques. The second requirement
was that it have adequate function from the outset, because I was determined
that there would be no second version of the program.
The program's speed of response would not be important, although it did
have to accept input at my normal typing rate. It wouldn't need to handle
large files; by the time I needed to edit large files, there would be a good
editor on the market.
With these factors in mind, I sketched the parameters of the program. It
would keep a file of a couple hundred lines in storage as an array of strings.
Lines would be no longer than the screen was wide. In fact, for simplicity
of coding, no line would be shorter than the screen width either.
It would present the file on the screen 24 lines at a time. The user
would be able to move the cursor to insert, delete or type over characters.
The special keypad functions of the PC keyboard would be supported to move
the cursor over the screen and the screen over the file. There would be
control key signals to delete and insert lines and to move to the head and
foot of the file.
The only disk I/O that would be required would be the ability to save the
working file on disk and to load another file from disk. Since there would
never be a great amount of data at risk, error-checking and reporting would
be minimal.
These were the objectives, let's look at the program that resulted.
USING STOPGAP.
The Stopgap Editor is loaded and executed like any other program in Basic.
Shortly after starting, it presents you with a clear screen.
The screen now becomes the electronic equivalent of a roll of paper.
Each screen line corresponds to a line of characters in a disk file. Move
the cursor around with the up-,down-,left- and right-arrow keys and type
anywhere you like.
The enter key moves the cursor to the left margin and down one line-
without putting any data in the file. The tab key moves the cursor to the
next tab stop. It doesn't put any data in the file either.
The end key moves the cursor to the right side of the screen. The home
key does one of three things, depending on where the cursor is when you
press it. If the cursor is away from the left margin, the home key moves it
back to the left margin. If the cursor is at the left margin but not on the
top line, then the home key moves it to the top line. If the cursor is in
the top left corner, the home key moves it to the bottom left corner. With
a few presses of the home and end keys, you can move to any corner of the
screen. (I took this idea from the Magic Wand editor for CP/M.)
Type some characters on the screen. Move the cursor into the middle of
a word and press the insert key. The cursor becomes double, framing the
current character. (On the top line of the screen, the upper half of the
cursor is invisible.)
Now, each character you type will be inserted ahead of the current character.
If the line is full, one character will be lost from the right end for each one
inserted. Pressing any key except a printable character will end insert mode.
You'll find that the backspace key erases the current character and moves
cursor to the left. Press the delete key and the current character disappears
while the rest of the line shifts to the left to fill in and the cursor stays
in place.
If you keep inserting or deleting for about 50 characters, the screen
seems to go dead. After a pause of about ten seconds, though, the system comes
to life again. This is a peculiarity of all Microsoft Basic interpreters.
The program has been doing several operations on character strings for
every inserted or deleted character, and the Basic interpreter has filled up
its working storage with garbage character strings. It stops to tidy up -
and when Basic stops, everything stops. When spring cleaning is over, work
resumes.
PAGING THROUGH THE FILE
On every line of your file, type a few characters and hit the enter key.
When you reach the bottom of the screen, keep going. The topmost lines scroll
out of sight.
Keep on typing for a while, then press the "PgUp" key on the keypad. The
editor moves back 23 lines, or to the top of the file. Note that the cursor
stays where it was on the screen. Press the "PgDn" key; the editor moves
forward 23 lines, or to the bottom of the file if that comes first.
Now try pressing the "Ctrl" and "A" together. That makes the editor move
the screen back to the top line of the file. Pressing "Ctrl" and "Z" causes
it to move to the last line used. This is how you move about in a larger file.
Use control-A to get to the top of the file and then use the page-down key, or
use control-Z to move to the end and then page up.
Go to the end of the file with control-Z, then move the cursor to the top
of the screen with the home key. Now press the up-arrow key. The editor
slides the screen up the file 23 lines and moves the cursor down 23 lines,
so that it is still on the line you were looking at.
LINE INSERTION AND DELETION
Hitting contol-D causes the editor to delete the entire line on which the
cursor rests. It redraws the whole screen afterward, so deletion is a fairly
slow process.
Inserting lines is a bit faster. When you press control-O, the editor
splits the file just above the line the cursor is on. The lower part of the
file is set aside. The line above the cursor becomes, temporarily, the
bottom of the file; the screen is blank beyond it. Each blank line you
type on becomes part of the file at that point.
When the file is open, you can use all the other controls for insertion.
You can page back into the upper part of the file to look at it; you can
delete lines or insert characters. Control-Z will take you not to the real end
of the file but to the line that was inserted last.
Once you have inserted as many lines as you want, press control-C. The
editor splices the file back into a single piece, with the inserted lines
embedded where you typed them. (This method of insertion is also copied
from the Magic Wand editor.)
COMMANDS
The Stopgap Editor supports just four commands. Press the "Esc" key. The
editor clears the screen and displays a menu of the commands. Pressing the
enter key will return you to the file display.
The save command asks for a filespec and copies the entire file to disk
under that name. (If you give it a filespec of "lpt1:", it will copy the
file to the printer!) The editor deletes trailing blanks from the end of the
lines saved and discards empty lines at the end of the file.
The load command asks for a filespec and loads the lines of that file into
storage for editing. It truncates long lines to the width of the screen
(but doesn't tell you it has done so). The clear command wipes out everything,
giving you a blank scroll to work on. The quit command returns you to the
system. If you have added or changed anything in the file, these commands
ask for confirmation before they act.
The Stopgap Editor's disk operations are painfully slow. It takes a couple
of minutes to load a file of a hundred lines. If there is any sort of file
error - if the disk fills up during a save, for example - you'll get an
error message from Basic.
Your work hasn't been lost though. Kill another file to get some space,
then enter the command GOTO 1630. You should be back in the editor with your
data intact. But remember, this editor is only a stopgap. Save your work
often.
This disk copy was originally provided by "The Public Library",
the software library of the Houston Area League of PC Users.
Disks in the Public Libray are updated monthly. Check with us
for the latest versions of all programs.
Programs are available from the Public Library at $2 per disk
on user-provided disks. To get a listing of the disks in the
Public Library, send a self-addressed, stamped envelope to
Nelson Ford, P.O.Box 61565, Houston, TX 77208.